package aer.MenorNumeroMismaSumaDigitos;

import java.io.*;

public class MenorNumeroMismaSumaDigitos {
	private static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());

		while (n != 0) {
			programa(n);
			n = Integer.parseInt(br.readLine());
		}
		
		out.flush();
	}

	private static void programa(int n) {
		if (n < 10) {
			out.print(n+"\n");
		} else {
			calcular(n);
		}
	}

	private static void calcular(int n) {
		StringBuilder acc = new StringBuilder("9");
		int sum = 0;

		for (int i = 10; i <= n; i++) {
			sum++;
			if (sum == 10) {
				sum = 1;
				acc.append("9");
			}
		}

		out.print(sum + acc.toString()+"\n");

	}
}